package com.shy.advice;

import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class UserService {
    // 增删改查
    public void add() {
        System.out.println("add");
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    public void delete(Long id) {
        System.out.println("delete");
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    public Long update(Long id) {
        System.out.println("update");
        try {
            TimeUnit.SECONDS.sleep(1);
            int i = 1 / 0;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        throw new RuntimeException("出错了");
    }

    public String select(Long id) {
        System.out.println("select");
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return "select retrun " + id;
    }
}
